package com.cskaoyan.controller;

import com.cskaoyan.bean.data.PageData;
import com.cskaoyan.bean.vo.BaseRespVo;
import com.cskaoyan.model.MarketBrand;
import com.cskaoyan.service.BrandService;
import com.cskaoyan.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("wx/brand")
public class WxBrandController {
    @Autowired
    BrandService brandService;
    @Autowired
    GoodsService goodsService;

    @GetMapping("list")
    public BaseRespVo list(Integer page, Integer limit) {
        List<MarketBrand> brandList = brandService.list(page, limit);
        PageData pageData = PageData.list(brandList);
        return BaseRespVo.ok(pageData);
    }

    @GetMapping("detail")
    public BaseRespVo detail(Integer id) {
        MarketBrand marketBrand = brandService.findByBrandId(id);
        if (marketBrand == null) {
            return BaseRespVo.badArgumentValue();
        }
        return BaseRespVo.ok(marketBrand);
    }
}
